import Vue from 'vue';
import Vuex from 'vuex';
import vueRouter from 'vue-router';
import news from '../components/news/news.vue';
import read from '../components/read/read.vue';
import media from '../components/media/media.vue';
import person from '../components/person/person.vue';
Vue.use(vueRouter);
Vue.use(Vuex);

var  router =  new vueRouter({
	routes: [{
		name:'news',
  		path: '/news',
  		component: function (resolve) {
    		require(['../components/news/news.vue'], resolve)
  			}
	}, {
		name:'read',
  		path: '/read',
  		component: function (resolve) {
    		require(['../components/read/read.vue'], resolve)
  			}
	}, {
		name:'media',
  		path: '/media',
  		component: function (resolve) {
    		require(['../components/media/media.vue'], resolve)
  			}
	}, {
		name:'person',
  		path: '/person',
  		component: function (resolve) {
    		require(['../components/person/person.vue'], resolve)
  			}
	}, {
		redirect: 'news', // 当访问的路径为根路径的时候，自动重定向到home 路由 
		path: '/'
	}]
})


router.beforeEach(function (to, from, next) {
	window.isLoading=true;
	console.log(1)
  //store.commit('updateLoadingStatus', {isLoading: true})
  next()
})
router.afterEach(function (to) {
  window.isLoading=false;
  console.log(22)
})
export default router;
